package com.qd.common.sys.domain.entity.log;

import com.cdqidi.config.JsonObjectSerializer;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 数据日志
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class DataLogDTO extends BaseQuery {
    /**
     * 主键
     */
    @NotBlank(message = "日志ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "日志ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String logId;
    /**
     * 用户ID
     */
    @Size(max = 50, message = "用户ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String userId;
    /**
     * 用户姓名
     */
    @Size(max = 200, message = "用户姓名长度不能超过{max}位", groups = DefaultGroup.class)
    private String userName;
    /**
     * IP地址
     */
    @Size(max = 20, message = "IP地址长度不能超过{max}位", groups = DefaultGroup.class)
    private String userIp;
    /**
     * 模块标题
     */
    @Size(max = 50, message = "模块标题长度不能超过{max}位", groups = DefaultGroup.class)
    private String title;
    /**
     * 方法名称
     */
    @Size(max = 200, message = "方法名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String method;
    /**
     * 登录类型:电脑端或者手机端
     */
    @Size(max = 50, message = "登录类型:电脑端或者手机端长度不能超过{max}位", groups = DefaultGroup.class)
    private String remote;
    /**
     * 登录类型显示值
     */
    private String remoteDisplay;
    /**
     * 请求方式
     */
    @Size(max = 20, message = "请求方式长度不能超过{max}位", groups = DefaultGroup.class)
    private String requestMethod;
    /**
     * 操作类型
     */
    @Size(max = 20, message = "操作类型长度不能超过{max}位", groups = DefaultGroup.class)
    private String operatorType;
    /**
     * 操作类型显示值
     */
    private String operatorTypeDisplay;
    /**
     * 组织机构名称
     */
    @Size(max = 200, message = "组织机构名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgName;
    /**
     * 请求URL
     */
    @Size(max = 100, message = "请求URL长度不能超过{max}位", groups = DefaultGroup.class)
    private String url;
    /**
     * 原始sql
     */
    @Size(max = 500, message = "原始sql长度不能超过{max}位", groups = DefaultGroup.class)
    private String rawSql;
    /**
     * 数据表
     */
    @Size(max = 200, message = "数据表长度不能超过{max}位", groups = DefaultGroup.class)
    private String tableName;
    /**
     * 内容
     */
    @JsonSerialize(using = JsonObjectSerializer.class)
    private String content;
    /**
     * 历史内容
     */
    @JsonSerialize(using = JsonObjectSerializer.class)
    private String historyContent;
    /**
     * 方法名
     */
    @Size(max = 200, message = "方法名长度不能超过{max}位", groups = DefaultGroup.class)
    private String daoMethodName;
    /**
     * 执行SQL返回值:批量操作有值
     */
    private Integer sqlReturnId;
    /**
     * 操作时间
     */
    private LocalDateTime operatorTime;
    /**
     * SQL操作
     */
    @Size(max = 20, message = "SQL操作长度不能超过{max}位", groups = DefaultGroup.class)
    private String sqlCommandType;
    /**
     * 机构ID
     */
    @NotBlank(message = "机构ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "机构ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgId;

    @Override
    public void freeData() {
        this.logId = null;
        this.userId = null;
        this.userName = null;
        this.userIp = null;
        this.title = null;
        this.method = null;
        this.remote = null;
        this.remoteDisplay = null;
        this.requestMethod = null;
        this.operatorType = null;
        this.operatorTypeDisplay = null;
        this.orgName = null;
        this.url = null;
        this.rawSql = null;
        this.tableName = null;
        this.content = null;
        this.historyContent = null;
        this.daoMethodName = null;
        this.sqlReturnId = null;
        this.operatorTime = null;
        this.sqlCommandType = null;
        this.orgId = null;
        super.freeData();
    }
}
